package au.com.mason.propertyTracker.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import au.com.mason.propertyTracker.service.PropertyService;

@Controller
public class DeleteProperty {
	
	private PropertyService propertyService;

	@Autowired
	public DeleteProperty(PropertyService propertyService) {
		this.propertyService = propertyService;
	}
	
	@RequestMapping("/SubmitDeleteProperty.action")
	public String submitDeleteProperty(HttpSession session) {
		int propertyId = (Integer) session.getAttribute("propertyId");
		
		propertyService.deleteProperty(propertyId);
		
		return "redirect:SubmitFilterPropertiesFromSession.action";
	}

}
